//
//  NSString+secure.m
//  hundsun_zjfae
//
//  Created by 王金东 on 14-8-22.
//  Copyright (c) 2014年 王金东. All rights reserved.
//

#import "NSString+secure.h"
#import "HsSecureHander.h"


@implementation NSString (secure)

/**
 * 给字符串加密
 **/
- (NSString *)encoder{
    return [self encoderForKey:AESKEY];
}

/**
 * 解密
 **/
- (NSString *)decoder{
   return [self decoderForKey:AESKEY];
}

/**
 * 给字符串加密
 **/
- (NSString *)encoderForKey:(NSString *)key{
    NSData *data =   [HsSecureHander AES256Encrypt:self withKey:key];
    return [HsSecureHander dataToString:data];
}

/**
 * 解密
 **/
- (NSString *)decoderForKey:(NSString *)key{
    //加密后的 NSString  转换回 成 加密后的 nsdata
    NSData *data = [HsSecureHander stringToNsdata:self];
    return [HsSecureHander AES256Decrypt:data withKey:key];
}

@end
